package com.test.springmoudle.view.pojo;

import java.io.Serializable;

/**
 * Created by wangshida on 15/10/28.
 * Restful接口返回消息
 */
public class Status implements Serializable {
    private String code;
    private String msg;

    private final static String OK = "0";

    public Status() {
    }

    public Status(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static Status buildDone() {
        return build(StatusCode.DONE);
    }

    public static Status buildFailed() {
        return build(StatusCode.FAILED);
    }

    public static Status build(StatusCode resultCode) {
        return build(resultCode.getCode(), resultCode.getMsg());
    }

    public static Status build(String code, String msg) {
        return new Status(code, msg);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "Status{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                '}';
    }
}
